home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_07 / greissma / point.h < prev   
C/C++ Source or Header  |  1994-03-09  |  704b  |  30 lines

  1. Listing 6: Implementation of a Point Mapped object
  2.  
  3. class Point : public MappedObject {
  4.     int x, y;
  5.     char *text;
  6.     static Map map;
  7.     static Field *fieldv[];
  8. public:
  9.     Point();
  10.     Point( int x, int y, char *text );
  11. } ;
  12.  
  13. Field *Point::fieldv[] = {
  14.     new IntField  ( "x",    offsetof( Point, x ) ),
  15.     new IntField  ( "y",    offsetof( Point, y ) ),
  16.     new CharField ( "text", offsetof( Point, text ) ),
  17. } ;
  18.  
  19. Map Point::map( "Point", fieldv, sizeof(Point::fieldv) / sizeof(Point*) );
  20.  
  21. Point::Point()
  22.       :MappedObject( map ), x( 0 ), y( 0 ), text( "" )
  23. {
  24. }
  25.  
  26. Point::Point( int x, int y, char *text )
  27.       :MappedObject( map ), x( x ), y( y ), text( text )
  28. {
  29. }
  30.